<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<html>
<head>
    <title>江苏高考志愿填报系统</title>
    <link rel="stylesheet" href="css/bootstrap.min.css" >
    <link href="css/main.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" type="text/css" href="css/sweetalert.css">
    <script src="js/sweetalert.min.js"></script>
    <script type="text/javascript" src="js/jquery-3.3.1.js"></script>
    <script type="text/javascript" src="js/bootstrap.min.js"></script>
</head>
<body>
<h1>江苏高考志愿填报系统</h1>
<div class="login-form">
    <div class="head-info">
        <label class="lbl-1"> </label>
        <label class="lbl-2"> </label>
        <label class="lbl-3"> </label>
    </div>
    <div class="clear"> </div>
    <div class="avtar">
        <img src="images/avtar.png" />
    </div>
    <form>
        <input type="text" class="user_name"  id="stu_name" placeholder = "考生姓名" >
        <input type="text" class="identity"  id="stu_identity" placeholder = "输入身份证号">
        <input type="button" class="btn btn-warning" id="login_btn" value="登&nbsp;&nbsp;录" onclick="login()">
    </form>
</div>
<script>

    $("body").keydown(function() {
        if (event.keyCode == "13") {//keyCode=13是回车键
            login();
        }
    });

    function login(){
        if($('#stu_name').val().length == 0){
            swal("请输入您的姓名");
        }
        else if($("#stu_identity").val().length == 0){
            swal("请输入身份证号");
        }
        else{
            var rule = /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/;
            if(!rule.test($("#stu_identity").val())){
                swal("身份证号码格式不规范");

            }
            else {
                $.post("check_login",{
                    "name": $('#stu_name').val(),"identity": $("#stu_identity").val()
                },function(data){
                    if(data == "false"){
                        swal("请确认姓名及身份证号");
                    }
                    else{
                        swal("Welcome!", "欢迎考生:  "+$('#stu_name').val(), "success");
                        window.setTimeout(function(){location.href = "/main";}, 2000);
                    }
                })
            }
        }}

</script>
</body>
</html>
